<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>图标制作器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            background: #f5f5f5;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        .icon-row {
            display: flex;
            justify-content: space-around;
            margin: 20px 0;
            flex-wrap: wrap;
        }
        .icon-item {
            text-align: center;
            margin: 10px;
            padding: 15px;
            background: #f8f9fa;
            border-radius: 8px;
        }
        canvas {
            border: 1px solid #ddd;
            margin-bottom: 10px;
            border-radius: 4px;
        }
        button {
            background: linear-gradient(45deg, #667eea, #764ba2);
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 12px;
        }
        button:hover {
            opacity: 0.9;
        }
        .instructions {
            background: #e3f2fd;
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎨 扩展图标制作器</h1>
        
        <div class="instructions">
            <strong>使用说明：</strong>
            <ol>
                <li>点击下载按钮保存图标</li>
                <li>将文件重命名为 icon16.png, icon32.png, icon48.png</li>
                <li>复制到 dist/icons/ 目录</li>
                <li>重新加载Chrome扩展</li>
            </ol>
        </div>
        
        <div class="icon-row">
            <div class="icon-item">
                <canvas id="icon16" width="16" height="16"></canvas>
                <br>
                <button onclick="download('icon16', 'icon16.png')">下载 16x16</button>
            </div>
            
            <div class="icon-item">
                <canvas id="icon32" width="32" height="32"></canvas>
                <br>
                <button onclick="download('icon32', 'icon32.png')">下载 32x32</button>
            </div>
            
            <div class="icon-item">
                <canvas id="icon48" width="48" height="48"></canvas>
                <br>
                <button onclick="download('icon48', 'icon48.png')">下载 48x48</button>
            </div>
        </div>
    </div>

    <script>
        function drawIcon(canvasId, size) {
            const canvas = document.getElementById(canvasId);
            const ctx = canvas.getContext('2d');
            
            // 清除画布
            ctx.clearRect(0, 0, size, size);
            
            // 创建渐变
            const gradient = ctx.createLinearGradient(0, 0, size, size);
            gradient.addColorStop(0, '#667eea');
            gradient.addColorStop(0.5, '#764ba2');
            gradient.addColorStop(1, '#f093fb');
            
            // 绘制圆形背景
            ctx.beginPath();
            ctx.arc(size/2, size/2, size/2 - 1, 0, 2 * Math.PI);
            ctx.fillStyle = gradient;
            ctx.fill();
            
            // 绘制白色边框
            ctx.beginPath();
            ctx.arc(size/2, size/2, size/2 - 1, 0, 2 * Math.PI);
            ctx.strokeStyle = 'rgba(255,255,255,0.3)';
            ctx.lineWidth = 1;
            ctx.stroke();
            
            // 绘制图标内容
            ctx.fillStyle = 'white';
            ctx.textAlign = 'center';
            ctx.textBaseline = 'middle';
            
            if (size === 16) {
                ctx.font = 'bold 10px Arial';
                ctx.fillText('R', size/2, size/2);
            } else if (size === 32) {
                ctx.font = 'bold 20px Arial';
                ctx.fillText('R', size/2, size/2);
            } else {
                ctx.font = 'bold 30px Arial';
                ctx.fillText('R', size/2, size/2);
            }
        }
        
        function download(canvasId, filename) {
            const canvas = document.getElementById(canvasId);
            const link = document.createElement('a');
            link.download = filename;
            link.href = canvas.toDataURL('image/png');
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
            
            // 显示反馈
            event.target.textContent = '✓ 已下载';
            setTimeout(() => {
                event.target.textContent = `下载 ${canvasId.replace('icon', '')}x${canvasId.replace('icon', '')}`;
            }, 2000);
        }
        
        // 页面加载时绘制图标
        window.onload = function() {
            drawIcon('icon16', 16);
            drawIcon('icon32', 32);
            drawIcon('icon48', 48);
        };
    </script>
</body>
</html>
